<?php

namespace WoXuanWang\Dashboard\Requests;

use Illuminate\Foundation\Http\FormRequest;
use WoXuanWang\Customer\Models\Customer;
use Illuminate\Validation\Rule;

class SetImageRequest extends FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'position'  => 'required',
            'upload_id' => ['required',
                Rule::exists('uploads', 'id')->where(function ($query) {
                    $query->where('user_id', \Auth::id());
                })
            ],
        ];

        return $rules;
    }
}
